package com.example.xpagedemoproject.fragment;

import android.view.View;

import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.base.XPageContainerListFragment;
import com.xuexiang.xpage.core.PageOption;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xpage.utils.TitleBar;
import com.xuexiang.xutil.common.ClickUtils;

@Page(name = "XPage",anim = CoreAnim.none)
public class MainFragment extends XPageContainerListFragment {
    @Override
    protected Class[] getPagesClasses() {
        return new Class[]{
                DataTransmitFragment.class,
                AnimationFragment.class,
                ComplexPageFragment.class,
                PopBackFragment.class,
                PageOptionFragment.class,
                BottomNavigationViewFragment.class
        };
    }

    @Override
    protected TitleBar initTitleBar() {
        TitleBar titleBar = super.initTitleBar();
        titleBar.setLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClickUtils.exitBy2Click();
            }
        });
        return titleBar;
    }

    @Override
    protected void onItemClick(int position) {
        if (position == 3) {
            PageOption.to(getSimpleDataItem(position))
                    .setNewActivity(true)
                    .setAnim(CoreAnim.slide)
                    .open(this);
        }else{
            super.onItemClick(position);

        }
    }
}
